package com.guapi.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


/**
 * 注册拦截器
 *  将拦截器注册到了拦截器列表中,并且指明了拦截哪些访问路径,不拦截哪些访问路径,不拦截哪些资源文件
 */
@Configuration
public class WebConfigMvc implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        注册自定义拦截器
        registry.addInterceptor(loginInterceptor)
//                先确定拦截哪些路径 /**代表所有
        .addPathPatterns("/**")
//        确定哪些路径不拦截
        .excludePathPatterns("/login","/static/**");
    }

}
